<?php
namespace zhtfrontend\modules\cus\models\forms;
use common\components\extenders\MenuManage;
use yii\base\Model;

class OrdersForm extends Model
{
    public $goods_id;
    public $goods_price_id;
    public $total_amount;
    public $remarks;
    public $final_amount;
    public $discount_amount;
    public $total;

    public function rules()
    {
        return [
            [['goods_id','goods_price_id'], 'integer'],
            [['goods_id'], 'required'],
            [['total_amount','final_amount','discount_amount','total'], 'number'],
            [['remarks'], 'string'],
            [['total'], 'required','on'=>'recharge'],
        ];
    }
    public function attributeLabels()
    {
        return [
            'goods_id' => \Yii::t('zhtfrontend', '商品id'),
            'goods_price_id' => \Yii::t('zhtfrontend', '价格'),
            'remarks' => \Yii::t('zhtfrontend', '备注'),
            'total_amount' => \Yii::t('zhtfrontend', '订单金额'),
            'final_amount' => \Yii::t('zhtfrontend', '实付金额'),
            'discount_amount' => \Yii::t('zhtfrontend', '优惠金额'),
            'total' => \Yii::t('zhtfrontend', '充值金额'),
        ];
    }

//    public function fields()
//    {
//        $fields = parent::fields();
//        $fields['status'] = function () {
//            switch ($this->status) {
//                case 0:
//                    return \Yii::t('zhtfrontend', '已停用');
//                case 1:
//                    return \Yii::t('zhtfrontend', '已激活');
//            }
//        };
//        $fields['created_at'] = function () {
//            return \Yii::$app->formatter->asDatetime($this->created_at);
//        };
//        unset($fields['password']);
//        return $fields;
//    }

    public function extraFields()
    {
        return [
            'operate' => function () {
                return (new MenuManage(MenuManage::RECORD_ITEM_TOOLBAR, $this->attributes))->create();
            },
        ];
    }


}
